<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


<c:choose>
	<c:when test="${not empty fornecedores}">
		<form id="defaultForm" class="form" action="${pageContext.request.contextPath}/fornecedor/update" method="POST">
	</c:when>
	<c:otherwise>
		<form id="defaultForm" class="form" action="${pageContext.request.contextPath}/fornecedor/save" method="POST">
	</c:otherwise>
</c:choose>

	<div class="span9">
		<div class="well well-large">
		
			<c:if test="${not empty errors}">
				<c:forEach items="${errors}" var="error">
					<div class="alert alert-error">
						<button name="skipAjax" type="button" class="close" data-dismiss="alert">&times;</button>
						${error.message}
					</div>
				</c:forEach>
			</c:if>
		
			<ul class="thumbnails">
				<li class="span4"> 
					<i class="icon-briefcase"></i> <fmt:message key="BUNDLE_SUPPLIER"/>
				
			    	<div class="thumbnail">
			    	
			    		<input type="hidden" name="fornecedor.id" value="${fornecedor.id}"/>
			    	
						<div class="field">
							<fmt:message key="BUNDLE_NOME"/><br />
						
							<input type="text" name="fornecedor.nome" value="${fornecedor.nome}" required/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_MAIN_PHONE"/><br />
								
							<input type="text" name="fornecedor.telefone1" placeholder="(99)9999-9999" 
									value="${fornecedor.telefone1}" data-mask="(99)9999-9999" required />
						</div>
							
						<div class="field">
							<fmt:message key="BUNDLE_SECOND_PHONE"/><br />
							
							<input type="text" name="fornecedor.telefone2" placeholder="(99)9999-9999" 
								value="${fornecedor.telefone2}" data-mask="(99)9999-9999"/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_EMAIL"/><br />
								
							<input type="email" name="fornecedor.email" placeholder="nome@email.com.br"
								value="${fornecedor.email}"/>
						</div>
						
					</div>
				</li>
				<li class="span4">
		      		<i class="icon-road"></i> <fmt:message key="BUNDLE_ADRESS"/>
			    	
			    	<div class="thumbnail">
				
						<div class="field">
							<fmt:message key="BUNDLE_LOGRADOURO"/><br />
						
							<input type="text" name="fornecedor.endereco.logradouro" 
								value="${fornecedor.endereco.logradouro}" required/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_NUMERO"/><br />
						
							<input type="text" name="fornecedor.endereco.numero" 
								value="${fornecedor.endereco.numero}" required/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_BAIRRO"/><br />
						
							<input type="text" name="fornecedor.endereco.bairro" 
								value="${fornecedor.endereco.bairro}"/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_COMPLEMENTO"/><br />
						
							<input type="text" name="fornecedor.endereco.complemento" 
								value="${fornecedor.endereco.complemento}"/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_CIDADE"/><br />
						
							<input type="text" name="fornecedor.endereco.cidade" 
								value="${fornecedor.endereco.cidade}" required/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_ESTADO"/><br />
							
							<select class="selectpicker" name="fornecedor.endereco.estado">
								<option value = "">- Selecione -</option>
								<c:if test="${not empty estadosBrasileiros}">
									<c:forEach items="${estadosBrasileiros}" var="estado">
										<option value="${estado}" <c:if test="${fornecedor.endereco.estado eq estado}">selected</c:if>>
											${estado}
										</option>
									</c:forEach>
								</c:if>
							</select>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_PAIS"/><br />
						
							<input type="text" name="fornecedor.endereco.pais" 
								value="${fornecedor.endereco.pais}"/>
						</div>
						
						<div class="field">
							<fmt:message key="BUNDLE_CEP"/><br />
						
							<input type="text" name="fornecedor.endereco.cep" placeholder="99.999-999" 
								value="${fornecedor.endereco.cep}" data-mask="99.999-999"/>
						</div>
			    	</div>
			  	</li>
			</ul>
		</div>
	</div>
			
	<div class="span3">
		<div class="actions">
			<button name="submit" type="submit" class="btn btn-success">
				<i class="icon-ok icon-white"></i> <fmt:message key="BUNDLE_CONFIRM"/>
			</button>
			
			<a class="btn btn-warning" href="${pageContext.request.contextPath}/fornecedor">
				<i class="icon-share-alt icon-white"></i> <fmt:message key="BUNDLE_BACK"/>
			</a>
		</div>
	</div>
</form>
